import styles from './index.less'
import { Button, message } from 'antd'
import { RightCircleTwoTone } from '@ant-design/icons'
import { request } from 'umi'

const { clipboard } = require('electron')
const isDevelopment = process.env.NODE_ENV === 'development'

export default function IndexPage() {
  async function test() {
    // request('/api/test/get').then(res=>{
    //   console.log({res});
    //   clipboard.writeText(res);
    // })
    let user = {
      name: '李四',
      age: 4,
    }
    const res = await request('/api/test/post', { method: 'post', data: user, requestType: 'form' })
    if (isDevelopment) console.log('返回的数据：', res)
    clipboard.writeText(JSON.stringify(res))
    message.success(`token已复制到剪贴板`)
  }

  return (
    <div className={styles.page}>
      <Button onClick={test} type='primary' icon={<RightCircleTwoTone />}>
        获取token
      </Button>
    </div>
  )
}
